<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" type="text/css" href="../admin/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../admin/css/admin.css" />
	</head>
	<body>
		<div class="wrap-container">
			<center><p th:text="${category.id==null?'添加一级分类信息':'添加二级分类信息'}" style="font-size: 18px;margin-top: 15px"></p></center>
			<form class="layui-form" style="width: 90%;padding-top: 20px;">
					<div class="layui-form-item"  th:if="${category.id!=null}">
						<label class="layui-form-label">上级分类：</label>
						<div class="layui-input-block">
							<input type="text" name="parentName" disabled  th:if="${category!=null}"  autocomplete="off" class="layui-input layui-disabled" th:value="${category.name}">
						</div>
					</div>
				<input type="text" name="pid"   style="display: none"  th:value="${category.id==null?'0':category.id}">
				<input type="text" name="type"   style="display: none"  th:value="${category.id==null?'0':'1'}">
				<div class="layui-form-item">
					<label class="layui-form-label">分类名称：</label>
					<div class="layui-input-block">
						<input type="text" name="name" required lay-verify="required" placeholder="请输入分类名称" autocomplete="off" class="layui-input">
					</div>
				</div>
					<div class="layui-form-item" th:if="${category.id!=null}">
						<label class="layui-form-label">分类路径：</label>
						<div class="layui-input-block">
							<input type="text" name="page" required lay-verify="required" placeholder="请输入分类路径" autocomplete="off" class="layui-input">
						</div>

					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		</div>

		<script src="../admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/jquery-1.12.4.min.js"></script>
		<script>
			//Demo
			layui.use(['form'], function() {
				var form = layui.form();
				form.render();
				//监听提交
				form.on('submit(formDemo)', function(data) {
					$.post("../admin/category/save",data.field,function (result) {
						if (result=='ok'){
							window.location.replace("../admin/category")
						}
					})
					return false;
				});
			});
		</script>
	</body>

</html>